<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/share/mui.indexedlist.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/share/common.css" />
		<script type="text/javascript" src="../js/vue.min.js"></script>
		<style>
		html,
			body {
				height: 100%;
				overflow: hidden;
			}
			
			.mui-bar {
				-webkit-box-shadow: none;
				box-shadow: none;
			}
			
			.mui-input-row.mui-search .mui-icon-clear {
				display: none;
			}
		}
		</style>
	</head>

	<body id="cityList">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left header-left"></a>
			<h1 class="mui-title">城市列表</h1>
		</header>
		<div class="mui-content">
			<div id='list' class="mui-indexed-list">
				<div class="mui-indexed-list-search mui-input-row mui-search">
					<input type="search" class="mui-input-clear mui-indexed-list-search-input" v-model="sinput" placeholder="搜索位置">
				</div>
				<div class="mui-indexed-list-bar">
					<a>A</a>
					<a>B</a>
					<a>C</a>
					<a>D</a>
					<a>E</a>
					<a>F</a>
					<a>G</a>
					<a>H</a>
					<a>I</a>
					<a>J</a>
					<a>K</a>
					<a>L</a>
					<a>M</a>
					<a>N</a>
					<a>O</a>
					<a>P</a>
					<a>Q</a>
					<a>R</a>
					<a>S</a>
					<a>T</a>
					<a>U</a>
					<a>V</a>
					<a>W</a>
					<a>X</a>
					<a>Y</a>
					<a>Z</a>
				</div>
				<div class="mui-indexed-list-alert"></div>
				<div class="mui-indexed-list-inner">
					<div class="mui-indexed-list-empty-alert">没有数据</div>
					<ul class="mui-table-view">

						<li data-group="A" class="mui-table-view-divider mui-indexed-list-group">A</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'a'| filterBy sinput in 'city'" data-tags={{list.pinyin}} data-value={{list.pinyin}}>{{list.city}}</li>

						<li data-group="B" class="mui-table-view-divider mui-indexed-list-group">B</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'b'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>

						<li data-group="C" class="mui-table-view-divider mui-indexed-list-group">C</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'c'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>

						<li data-group="D" class="mui-table-view-divider mui-indexed-list-group">D</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'd'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>

						<li data-group="E" class="mui-table-view-divider mui-indexed-list-group">E</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'e'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="F" class="mui-table-view-divider mui-indexed-list-group">F</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'f'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="G" class="mui-table-view-divider mui-indexed-list-group">G</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'g'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="H" class="mui-table-view-divider mui-indexed-list-group">H</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'h'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="J" class="mui-table-view-divider mui-indexed-list-group">J</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'j'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="K" class="mui-table-view-divider mui-indexed-list-group">K</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'k'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="L" class="mui-table-view-divider mui-indexed-list-group">L</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'l'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="M" class="mui-table-view-divider mui-indexed-list-group">M</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'm'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="N" class="mui-table-view-divider mui-indexed-list-group">N</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'n'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="P" class="mui-table-view-divider mui-indexed-list-group">P</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'p'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="Q" class="mui-table-view-divider mui-indexed-list-group">Q</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'q'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="R" class="mui-table-view-divider mui-indexed-list-group">R</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'r'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="S" class="mui-table-view-divider mui-indexed-list-group">S</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 's'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="T" class="mui-table-view-divider mui-indexed-list-group">T</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 't'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="T" class="mui-table-view-divider mui-indexed-list-group">U</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'u'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="T" class="mui-table-view-divider mui-indexed-list-group">V</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'v'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="W" class="mui-table-view-divider mui-indexed-list-group">W</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'w'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="X" class="mui-table-view-divider mui-indexed-list-group">X</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'x'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="Y" class="mui-table-view-divider mui-indexed-list-group">Y</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'y'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
						<li data-group="Z" class="mui-table-view-divider mui-indexed-list-group">Z</li>
						<li v-on:click="close(list.city)" class="mui-table-view-cell mui-indexed-list-item" v-for="list in Clist | cityFilter 'z'| filterBy sinput in 'city'" data-tags={{list.pinyin}}>{{list.city}}</li>
					</ul>
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.indexedlist.js"></script>
		<script type="text/javascript" src="../js/localData.js"></script>
		<script type="text/javascript" charset="utf-8">
			mui.init();
			var citylist = new Vue({
					el: "#cityList",
					data: {
						Clist: []
					},
					ready: function() {
						getJsonCity();
					},
					methods: {
						close: function(city) {
							localStorage.currentCity = writeData(city);
							var homeView = plus.webview.currentWebview().opener();
							//alert(JSON.stringify(plus.webview.all()))
							mui.fire(homeView, "changeCity");
							citylist.sinput = "";
							setTimeout(function() {
								mui.back();
							}, 100)
						}
					}
				})
				//获取城市列表数据
			function getJsonCity() {
				mui.getJSON(
					"../res/cityList.json", {},
					function(respon) {
						citylist.Clist = respon.citys;
						initCity();
					}
				)
			}
			//初始化城市列表
			function initCity() {
				var header = document.querySelector('header.mui-bar');
				var list = document.getElementById('list');
				//calc hieght
				list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';
				//create
				window.indexedList = new mui.IndexedList(list);
			}
			/*自定义过滤器
			 *value是过滤前数据
			 * begin表示过滤条件
			 */
			Vue.filter('cityFilter', function(value, begin) {
				var erg = new RegExp("^" + begin + "");
				var oArry = [];
				for (var i = 0; i < value.length; i++) {
					if (erg.test(value[i].pinyin)) {
						oArry.push(value[i]);
					}
				}
				return oArry;
			})
		</script>
	</body>

</html>